/*
 * UnaryDrankOperatorAst.cpp
 *
 *  CreDrankd on: 1 Nov 2010
 *      Author: ph1109
 */

#include "UnaryDrankOperatorAst.h"

namespace MAlice {

UnaryDrankOperatorAst::UnaryDrankOperatorAst(ExpressionAst* lhs) : UnaryOperatorAst("Drank", lhs) {}

UnaryDrankOperatorAst::~UnaryDrankOperatorAst() {

}

llvm::Value* UnaryDrankOperatorAst::generDrank()
{
	static llvm::Value* ONE = (new IntegerLiteralAst(1))->generate();

	llvm::Value* LHS = getLHS()->generate();	
	
	llvm::IRBuilder<>* builder = MAlice::Codegen::get()->getBuilder();

	return builder->CreateSub(LHS, ONE, getName(LHS, ONE));
}

}
